#include "stdafx.h"

void game_machine :: cast_start  (short emit, short abil, short target)
{
    // the spell has been accepted, timer starts and further checks are made
    LOGMSG("[start] "+ inspect_cast(emit, abil, target));
    
    size_t pos;
    pool_timer(pos);
    Abilities[abil].on_cooldown = true;
    
    Timers[pos].abil = abil;
    Timers[pos].emit = emit;
    Timers[pos].target = target;
    if(Abilities[abil].cooltime > 0.0f) // charging spell
    {
        LOGMSG("Charging timer "+TO_STR(pos));
        Timers[pos].state = casting;
        Timers[pos].delay = Abilities[abil].cooltime;
        
        bar.period = Abilities[abil].cooltime;
        bar.current = 0;
        bar.inverse = 1.0f / Abilities[abil].cooltime;
    }
    else
        cast_launch(emit, abil, target);
}